<template>
    <view>
        <loading v-show="loading"></loading>
        <viewCom v-show="!loading" @setLoading='setLoading' :isOnShow='isOnShow' @setIsOnShow="setIsOnShow"></viewCom>
    </view>
</template>

<script>
    import viewCom from '@/components/view/index.vue'

    // 加载组件 && 加载混合剂
    import loading from '@/components/custom/loading.vue'
    import {
        loadingMixin
    } from '@/mixins/loading'

    import {
        getOptions
    } from '@/scripts/compatible/pageOptions.js'
    export default {
        mixins: [loadingMixin],
        components: {
            viewCom,
            loading,
        },
        mounted() {
            this.options_init()
        },
        onShow() {
            this.setIsOnShow(true)
        },
        data() {
            return {
                isOnShow: false,
            }
        },
        methods: {
            setIsOnShow(isOnShow) {
                this.isOnShow = isOnShow
            },
            options_init() {
                const options = getOptions()
                // id不存在 回到首页
                if (!options.id) {
                    uni.redirectTo({
                        url: '/pages/index/index'
                    })
                }
            },
        }
    }
</script>

<style>

</style>